//
//  GDBarViewController.m
//  爱新奇－味道
//
//  Created by 热带雨林 on 17/2/19.
//  Copyright © 2017年 热带雨林. All rights reserved.
//

#import "GDBarViewController.h"
#import "Masonry.h"
//#import <AFNetworking.h>
//#import <YYModel.h>
//#import "GDBarModel.h"
//#import "GDBarCell.h"



@interface GDBarViewController ()
//@property(nonatomic, weak)UITableView *tableView;
//@property (nonatomic, strong)NSArray <GDBarModel *> *modelArray;
@end


@implementation GDBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"其他";
    self.view.backgroundColor = [UIColor whiteColor];
    
//    [self loadData];
    
}
- (void)setupUI{
    UIWebView *webView = [[UIWebView alloc]init];
    [self.view addSubview:webView];
    
    [webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    //直接加载网页
    //线程之间的通信
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSString *strURl = @"http://t10.nuomi.com/webapp/na/topten?from=fr_na_t10tab&sizeLimit=8&version=2&needstorecard=1&areaId=100010000&location=39.989430,116.324470&bn_aid=ios&bn_v=5.13.0&bn_chn=com_dot_apple";
        NSURL *url = [NSURL URLWithString:strURl];
        //拼接出一个请求
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        //回到主线程，刷新UI
        dispatch_async(dispatch_get_main_queue(), ^{
            [webView loadRequest:request];
        });
    });
}

//- (void)setupUI{
//    
//    UITableView *tableView = [[UITableView alloc]init];
//    self.tableView = tableView;
//    self.tableView.delegate = self;
//    self.tableView.dataSource = self;
//    
//    self.tableView.estimatedRowHeight = 100;
//    self.tableView.rowHeight = UITableViewAutomaticDimension;
//    
//    [self.view addSubview:tableView];
//    
//    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.view);
//    }];
//    
//    [tableView registerClass:[GDBarCell class] forCellReuseIdentifier:cellID];
//    
//}
//- (void)loadData{
//
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
//    NSString *strURL = @"http://app.nuomi.com/naserver/home/homepage?appid=ios&bduss=&channel=com_dot_apple&cityid=100010000&cuid=11a2e62839f7bed05437dcb826be61a0c47a515c&device=iPhone&ha=5&lbsidfa=ACAF9226-F987-417B-A708-C95D482A732D&location=39.989360%2C116.324490&logpage=Home&net=unknown&os=8.2&sheight=1334&sign=40c974d176568886ad0e72516645e23f&swidth=750&terminal_type=ios&timestamp=1442906717563&tn=ios&uuid=11a2e62839f7bed05437dcb826be61a0c47a515c&v=5.13.0";

//    [manager GET:strURL parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//    
//        NSDictionary *dic = responseObject[@"data"];
//        NSArray *categoryArray = dic[@"category"];
//        
//        //字典转模型 转换为自己需要的model数组
//        NSArray *modelArray = [NSArray yy_modelArrayWithClass:[GDBarModel class] json:categoryArray];
//        
//        self.modelArray = modelArray;
//        
//        [self.tableView reloadData];
//        
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//   
//    }];
//    [manager POST:strURL parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSDictionary *dic = responseObject[@"data"];
//        NSArray *categoryArray = dic[@"category"];
//        
//        //字典转模型 转换为自己需要的model数组
//        NSArray *modelArray = [NSArray yy_modelArrayWithClass:[GDBarModel class] json:categoryArray];
//        
//        self.modelArray = modelArray;
//        
//        [self.tableView reloadData];
//        
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        
//    }];
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return self.modelArray.count;
//}
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//
//    GDBarCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//    
//    cell.barModel = self.modelArray[indexPath.row];
//    
//    return cell;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
